//
//  MCQiPaiDailyReportTableViewCell.m
//  TLYL
//
//  Created by MC on 2017/10/26.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCQiPaiDailyReportTableViewCell.h"
#import "MCDataTool.h"
#import "MCQiPaiReportTool.h"


@interface MCQiPaiDailyReportTableViewCell ()

@property (nonatomic,strong)UIImageView * logoImgV;
@property (nonatomic,strong)UILabel * timeLab;
//投注金额：20000.00       有效投注
//中奖金额：20000.00       房      费：20000.00
//其他收入                 对战盈亏：20000.00
//电子盈亏：1956～0.0       盈亏



//投注金额：20000.00
@property (nonatomic,strong)UILabel * tzMoneyLabel;
//有效投注
@property (nonatomic,strong)UILabel * ValidBetAmountLabel;

//房      费：80.00
@property (nonatomic,strong)UILabel * homeMoney;
//电子盈亏：1956～0.
@property (nonatomic,strong)UILabel * dianZiYinKuiMoney;
//盈亏
@property (nonatomic,strong)UILabel * PLMoney;

//中奖金额：20000.00
@property (nonatomic,strong)UILabel * zhongJiangMoney;
//其他收入
@property (nonatomic,strong)UILabel * otherMoneyLabel;
//对战盈亏：20000.00
@property (nonatomic,strong)UILabel * duiZhanMoney;


@end

@implementation MCQiPaiDailyReportTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }
    return self;
}

- (void)initView{
    
    self.backgroundColor=[UIColor clearColor];
    CGFloat font =12;
    if (G_SCREENWIDTH<370) {
        font=10;
    }
    
    UIView * back=[[UIView alloc]init];
    [self addSubview:back];
    back.backgroundColor=[UIColor whiteColor];
    back.frame=CGRectMake(13, 0, G_SCREENWIDTH-26, GetHeightWithLineCount(DaXiongQiPaiReportLineCount));
    back.layer.cornerRadius=6;
    back.clipsToBounds=YES;
    
    /*
     * logo
     */
    _logoImgV=[[UIImageView alloc]init];
    _logoImgV.backgroundColor=[UIColor whiteColor];
    [back addSubview:_logoImgV];
    _logoImgV.layer.cornerRadius=11;
    _logoImgV.clipsToBounds=YES;
    _logoImgV.image=[UIImage imageNamed:@"hjicon"];
    _logoImgV.frame=CGRectMake(22, 16, 22, 22);
    
    /*
     * 时间
     */
    _timeLab =[[UILabel alloc]init];
    _timeLab.textColor=RGB(46,46,46);
    _timeLab.font=[UIFont systemFontOfSize:font];
    _timeLab.text =@"加载中";
    _timeLab.textAlignment=NSTextAlignmentLeft;
    [self  addSubview:_timeLab];
    
    [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_logoImgV.mas_centerY).offset(0);
        make.left.equalTo(_logoImgV.mas_right).offset(7);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(20);
        
    }];
    
    
    
    
    UIView * centerView=[[UIView alloc]init];
    [self addSubview:centerView];
    centerView.backgroundColor=[[UIColor colorWithHexString:@"#ffa044"] colorWithAlphaComponent:0.13];//RGB(246,243,248);//RGB(246,243,248);
    centerView.frame=CGRectMake(33, 50, G_SCREENWIDTH-60, 20+30*DaXiongQiPaiReportLineCount);
    centerView.layer.cornerRadius=5;
    centerView.clipsToBounds=YES;
    
    
    
    //投注金额：20000.00
    UILabel * tzMoney=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 0) AndText:@"投注金额:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:tzMoney];
    UILabel * tzMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 0) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:tzMoneyLabel];
    _tzMoneyLabel=tzMoneyLabel;
    
    
    //有效投注
    UILabel * ValidBetAmount=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(1, 0) AndText:@"有效投注:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:ValidBetAmount];
    UILabel * ValidBetAmountLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(1, 0) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:ValidBetAmountLabel];
    _ValidBetAmountLabel=ValidBetAmountLabel;
    
    //中奖金额：20000.00
    UILabel * zhongJiang=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 1) AndText:@"中奖金额:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:zhongJiang];
    UILabel * zhongJiangMoney=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 1) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:zhongJiangMoney];
    _zhongJiangMoney=zhongJiangMoney;
    
    
    //房      费：20000.00
    UILabel * home=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(1, 1) AndText:@"房      费:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:home];
    UILabel * homeMoney=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(1, 1) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:homeMoney];
    _homeMoney=homeMoney;
    
    //其他收入
    UILabel * otherMoney=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 2) AndText:@"其他收入:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:otherMoney];
    UILabel * otherMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 2) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:otherMoneyLabel];
    _otherMoneyLabel=otherMoneyLabel;
    
    //对战盈亏：20000.00
    UILabel * duiZhan=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(1, 2) AndText:@"对战盈亏:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:duiZhan];
    UILabel * duiZhanMoney=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(1, 2) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:duiZhanMoney];
    _duiZhanMoney=duiZhanMoney;
    
    //电子盈亏：1956～0.
    UILabel * dianZiYinKui=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 3) AndText:@"电子盈亏:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:dianZiYinKui];
    UILabel * dianZiYinKuiMoney=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 3) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:dianZiYinKuiMoney];
    _dianZiYinKuiMoney=dianZiYinKuiMoney;
    
    
    /*
     * 盈亏
     */
    UILabel * PL=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(1, 3) AndText:@"盈      亏:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:PL];
    UILabel * PLMoney=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(1, 3) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:PLMoney];
    _PLMoney=PLMoney;
    
  
    
}


-(UILabel *)GetAdaptiveLable:(CGRect)rect AndText:(NSString *)contentStr andFont:(CGFloat)font  andTextColor:(UIColor *)textColor andTextAlignment:(NSTextAlignment)textAlignment;
{
    
    
    UILabel *contentLbl = [[UILabel alloc] initWithFrame:rect];
    contentLbl.text = contentStr;
    contentLbl.numberOfLines = 0;
    contentLbl.textAlignment = textAlignment;
    contentLbl.font = [UIFont systemFontOfSize:font];
    contentLbl.textColor=textColor;
    contentLbl.clipsToBounds=YES;
    
    return contentLbl;
}


+(CGFloat)computeHeight:(id)info{
    
    return GetHeightWithLineCount(DaXiongQiPaiReportLineCount)+10;
}

-(void)setDataSource:(MCThirdQiPaiReportlstModel *)dataSource{
    
    if (!dataSource) {
        return;
    }
    
    //投注金额：20000.00
    _tzMoneyLabel.text=GetRealSNum(dataSource.GamePay);
    
    //有效投注
    _ValidBetAmountLabel.text = GetRealSNum(dataSource.ValidBetAmount);
    
    //房      费：20000.00
    _homeMoney.text=GetRealSNum(dataSource.RoomFee);
    //电子盈亏：1956～0.
    _dianZiYinKuiMoney.text=GetRealSNum(dataSource.SystemIncome);
    [MCDataTool changeYKLabelColor:_dianZiYinKuiMoney];
    //中奖金额：20000.00
    _zhongJiangMoney.text=GetRealSNum(dataSource.GameGet);
    //对战盈亏：20000.00
    _duiZhanMoney.text=GetRealSNum(dataSource.PlayIncome);
    [MCDataTool changeYKLabelColor:_duiZhanMoney];
    //盈亏
    _PLMoney.text = GetRealSNum(dataSource.PL);
    [MCDataTool changeYKLabelColor:_PLMoney];
    
    
    
    NSDateFormatter *dataFormatter = [[NSDateFormatter alloc] init];
    [dataFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *dateTemps = [dataFormatter dateFromString:dataSource.HisDate];
    [dataFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateTempMinStr = [dataFormatter stringFromDate:dateTemps];
    _timeLab.text=dateTempMinStr;
    _otherMoneyLabel.text = GetRealSNum(dataSource.OtherMoney);
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end



#pragma mark-开元棋牌
@interface MCKaiYuanQiPaiDailyReportTableViewCell ()

//游戏金额、其他收入、盈亏


//游戏金额、盈    亏（不能选择当日的数据报表）

@property (nonatomic,strong)UIImageView * logoImgV;
@property (nonatomic,strong)UILabel * timeLab;
//投注金额：20000.00  其他收入：20000.00
//盈      亏：25000.00

//投注金额：20000.00
@property (nonatomic,strong)UILabel * tzMoneyLabel;

//其他收入
@property (nonatomic,strong)UILabel * otherMoneyLabel;

//盈亏金额：25000.00
@property (nonatomic,strong)UILabel * yinKuiMoney;


@end

@implementation MCKaiYuanQiPaiDailyReportTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }
    return self;
}

- (void)initView{
    
    self.backgroundColor=[UIColor clearColor];
    CGFloat font =12;
    if (G_SCREENWIDTH<370) {
        font=10;
    }
    
    UIView * back=[[UIView alloc]init];
    [self addSubview:back];
    back.backgroundColor=[UIColor whiteColor];
    back.frame=CGRectMake(13, 0, G_SCREENWIDTH-26, GetHeightWithLineCount(KaiYuanQiPaiReportLineCount));
    back.layer.cornerRadius=6;
    back.clipsToBounds=YES;
    
    /*
     * logo
     */
    _logoImgV=[[UIImageView alloc]init];
    _logoImgV.backgroundColor=[UIColor whiteColor];
    [back addSubview:_logoImgV];
    _logoImgV.layer.cornerRadius=11;
    _logoImgV.clipsToBounds=YES;
    _logoImgV.image=[UIImage imageNamed:@"hjicon"];
    _logoImgV.frame=CGRectMake(22, 16, 22, 22);
    
    /*
     * 时间
     */
    _timeLab =[[UILabel alloc]init];
    _timeLab.textColor=RGB(46,46,46);
    _timeLab.font=[UIFont systemFontOfSize:font];
    _timeLab.text =@"加载中";
    _timeLab.textAlignment=NSTextAlignmentLeft;
    [self  addSubview:_timeLab];
    
    [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_logoImgV.mas_centerY).offset(0);
        make.left.equalTo(_logoImgV.mas_right).offset(7);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(20);
        
    }];
    
    
    
    
    UIView * centerView=[[UIView alloc]init];
    [self addSubview:centerView];
    centerView.backgroundColor=[[UIColor colorWithHexString:@"#ffa044"] colorWithAlphaComponent:0.13];//RGB(246,243,248);//RGB(246,243,248);
    centerView.frame=CGRectMake(33, 50, G_SCREENWIDTH-60, 20+30*KaiYuanQiPaiReportLineCount);
    centerView.layer.cornerRadius=5;
    centerView.clipsToBounds=YES;
    
    
    
    //投注金额：20000.00
    UILabel * tzMoney=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 0) AndText:@"游戏金额:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:tzMoney];
    UILabel * tzMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 0) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:tzMoneyLabel];
    _tzMoneyLabel=tzMoneyLabel;
    
    
    //其他收入
    UILabel * otherMoney=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(1, 0) AndText:@"其他收入:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:otherMoney];
    UILabel * otherMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(1, 0) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:otherMoneyLabel];
    _otherMoneyLabel=otherMoneyLabel;
    
    //盈      亏：25000.00
    UILabel * yinKui=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 1) AndText:@"盈      亏:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:yinKui];
    UILabel * yinKuiMoney=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 1) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:yinKuiMoney];
    _yinKuiMoney=yinKuiMoney;
    
    
}


-(UILabel *)GetAdaptiveLable:(CGRect)rect AndText:(NSString *)contentStr andFont:(CGFloat)font  andTextColor:(UIColor *)textColor andTextAlignment:(NSTextAlignment)textAlignment;
{
    
    
    UILabel *contentLbl = [[UILabel alloc] initWithFrame:rect];
    contentLbl.text = contentStr;
    contentLbl.numberOfLines = 0;
    contentLbl.textAlignment = textAlignment;
    contentLbl.font = [UIFont systemFontOfSize:font];
    contentLbl.textColor=textColor;
    contentLbl.clipsToBounds=YES;
    
    return contentLbl;
}


+(CGFloat)computeHeight:(id)info{
    
    return GetHeightWithLineCount(KaiYuanQiPaiReportLineCount)+10;
}

-(void)setDataSource:(MCThirdQiPaiReportlstModel *)dataSource{
    
    if (!dataSource) {
        return;
    }
    
    //投注金额：20000.00
    _tzMoneyLabel.text=GetRealSNum(dataSource.GamePay);
    
    //盈      亏：25000.00
    _yinKuiMoney.text=GetRealSNum(dataSource.PL);
    [MCDataTool changeYKLabelColor:_yinKuiMoney];
    NSDateFormatter *dataFormatter = [[NSDateFormatter alloc] init];
    [dataFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *dateTemps = [dataFormatter dateFromString:dataSource.HisDate];
    [dataFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateTempMinStr = [dataFormatter stringFromDate:dateTemps];
    _timeLab.text=dateTempMinStr;
    _otherMoneyLabel.text = GetRealSNum(dataSource.OtherMoney);
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
















